/*
package com.chi.elasticSearch;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.count.CountResponse;
import org.elasticsearch.action.deletebyquery.DeleteByQueryResponse;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.action.search.ShardSearchFailure;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.sort.SortOrder;

import com.botech.skynet.bas.domain.PassBean;
import com.botech.skynet.bas.domain.ResultBean;
import com.botech.skynet.bas.global.GlobalConfig;
import com.botech.skynet.bas.util.CommonUtil;
import com.botech.skynet.bas.util.JsonUtil;

*/
/**
 * 封装数据操作
 * <pre>
 *  插入操作：
 *    批量     insertDataBatch()
 *    非批量  insertData()
 *  删除操作：
 *     DeleteByQuery()按条件删除
 *   查询操作：
 *     获取全部数据 queryPassDataScroll() 滚动方式获取
 *     获取分页数据 queryESPageSort()  支持多字段按序排序
 *  工具类(static)：
 *    过车数据：将返回的Response转换为List	
 *		                convertPassResponse2List
 *	   过车数据：将返回的Response转换为Map :｛count:总数，time:耗时，list:数据集合｝
 *		               convertPassResponse2Map
 *     分析结果：将返回的Response转换为List
 *		               convertResultResponse2List
 *     分析结果：将返回的Response转换为Map :｛count:总数，time:耗时，list:数据集合}
 *		                convertResultResponse2Map
 *      获取32位UUID，不含"-"	 
 *	                getUUID() 
 *      构造时间对象:yyyy-MM-dd HH:mm:ss
 *		           parseDate()
 *		未识别车牌处理
 *        	Es查询（仅ES查询适用！！！)
 *                			QueryBuilder rexQuery = QueryBuilders.regexpQuery("plateNumNond", EsUtils.ILLEGAL_PLATE_NUMBER_REGEX_ES);            *         
 *      结果集中无牌车字段处理 setIllegalResultBean()
 *  </pre>
 *//*

public class EsUtils {
	private static final Logger logger = LoggerFactory.getLogger("EsUtils");
	private static final Client client=DataOperateClient.getInstance();
	private static final String PASS_TIME_FORMAT_MILLISECOND = "yyyy-MM-dd HH:mm:ss:SSS";
	private static final String PASS_TIME_START_MILLIS = ":000";
	private static final String PASS_TIME_END_MILLIS = ":999";
	public static final String ORDER_ASC = "ASC" ;
	public static final String ORDER_DESC = "DESC";	
	public static final Long insertBatchNum = 5000L;
	*/
/**
	 * ES入库失败重试次数
	 * *//*

	public static final int retryTimes = 2;
	*/
/**
	 * 判断未识别车牌号，仅适用于ES查询！！！ 【废弃】
	 * QueryBuilder rexQuery = QueryBuilders.regexpQuery("plateNumNond", EsUtils.ILLEGAL_PLATE_NUMBER_REGEX_ES);
	 *//*

	public static final String  ILLEGAL_PLATE_NUMBER_REGEX_ES  ="@&~((.{7,})|(WJ.{5,7}))";
	*/
/** 未识别的过车数据车牌号码数组 仅适用于ES查询  【废弃】 *//*

	public static final String[] ILLEGAL_PLATE_NUMBER_ES = new String[]{"0","-","","无车牌","未识别"};
	
	*/
/** 未识别判断标识 【新增-与卡口系统一致】 *//*

	public static final String ILLEGAL_PLATE_PLATETYPE_ES = "41";
	
	*/
/** 未识别的过车数据车牌号码 *//*

	public static final String  ILLEGAL_PLATE_NUMBER_NAME = "0";
	*/
/** 未识别的过车数据字段默认值 *//*

	public static final String  ILLEGAL_PLATE_FIELD_CODE = "--";
	
	*/
/** ES查询指定列-枚举*//*

	public static final String[] defaultFetchSources = {
		"uuid",
		"plateNumNond",
		"plateType",
		"plateTypeName",
		"bodyColorNond",
		"bodyColorName",
		"logoInfo",
		"passKako"
	};
	*/
/**存放ES所有可用索引集合*//*

	public static Set<String> indexSet = new HashSet<String>();
	
	*/
/**
	 *  批量插入数据
	 *  ES没有事物处理,建议的处理方式： catch 异常, 自己根据条件进行删除,然后重新插入
	 * @param entityList BeanList
	 * @param indexName 索引名称
	 * @param indexType 索引类型
	 * @return
	 * @throws Exception
	 *//*

	public BulkResponse insertDataBatch(List<Object> entityList,String indexName,String indexType)  throws Exception{		
		
		BulkRequestBuilder builder= client.prepareBulk();
		for(Object object:entityList){
			builder.add(client.prepareIndex(indexName,indexType).setSource(JsonUtil.writeValueAsString(object)));
		}
		BulkResponse bulkResponse = builder.execute().actionGet();
		
		return bulkResponse;
	}
	*/
/**
	 * 
	 * @param entityList
	 * @return
	 *//*

	public IndexResponse insertAnalysisResult(ArrayList<Map<String, Object>> entityList,String indexName,String typeName){
		IndexResponse indexResponse=null;
		try {
			if(entityList!=null&&entityList.size()>0){
				//遍历集合，将java对象转为json字符串后插入ES
				XContentBuilder doc = null;
				List<String> keys=new ArrayList<String>();
				Map<String, Object> map=entityList.get(0);
				if(map!=null){
					Iterator<String> it=map.keySet().iterator();
					while(it.hasNext()){
						keys.add(it.next());
					}
					if(keys!=null&&keys.size()>0){
						for(Map<String, Object> temp:entityList){
							//java对象转为Json字符串
							doc = XContentFactory.jsonBuilder()
									  .startObject();
							for(String key:keys){
								doc=doc.field(key, temp.get(key));
							}
							doc=doc.endObject();
							indexResponse= client.prepareIndex(indexName,typeName)
							 .setSource(doc)
							 .execute()
							 .actionGet();
						}
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return indexResponse;
	}
	*/
/**
	 * 
	 * @param entityList
	 * @return
	 *//*

	public BulkResponse insertResultBatch(List<Map<String, Object>> entityList,String indexName,String indexType)  throws Exception{		
		BulkRequestBuilder builder= client.prepareBulk();
		BulkResponse bulkResponse = null;
		//遍历集合，将java对象转为json字符串后插入ES
		XContentBuilder doc = null;
		List<String> keys=new ArrayList<String>();
		Iterator<String> it=entityList.get(0).keySet().iterator();
		while(it.hasNext()){
			keys.add(it.next());
		}
		for(Map<String, Object> object:entityList){
			//java对象转为Json字符串
			doc = XContentFactory.jsonBuilder().startObject();
			for(String key:keys){
				doc=doc.field(key, object.get(key));
			}
			doc=doc.endObject();
			builder.add(client.prepareIndex(indexName,indexType).setSource(doc));
		}
		bulkResponse = builder.execute().actionGet();
		
		return bulkResponse;
	}
	*/
/**
	 * 插入数据 非批量
	 * ES没有事物处理,建议的处理方式： catch 异常, 自己根据条件进行删除,然后重新插入
	 * @param entityList bean List
	 * @param indexName 索引名称
	 * @param indexType  索引类型
	 * @return
	 *//*

	public  IndexResponse insertData(ArrayList<Object> entityList,String indexName,String indexType) throws Exception{
		IndexResponse indexResponse=null;
		
			if(entityList!=null&&entityList.size()>0){
				//遍历集合，将java对象转为json字符串后插入ES
				for(Object  temp: entityList){					
					 indexResponse= client.prepareIndex(indexName,indexType)
					 .setSource(JsonUtil.writeValueAsString(temp))
					 .execute()
					 .actionGet();
				}
			}		
		return indexResponse;
	}
	
	*/
/**
	 * 删除数据 -- 根据查询条件
	 * ES没有事物处理,建议的处理方式： catch 异常, 自己根据条件进行删除,然后重新插入
	 * @param indexName 索引名称
	 * @param builder 查询条件 
	 * @return
	 *//*

	public DeleteByQueryResponse  DeleteByQuery(String  indexName,QueryBuilder builder) throws Exception{
		DeleteByQueryResponse response=null;
		response = (DeleteByQueryResponse)client.prepareDeleteByQuery(indexName).setQuery(builder).execute().actionGet();		
		return response;
	}
	
	*/
/**
	 * 查询过车数据 滚动方式获取全部数据
	 * @param query QueryBuilder
	 * @param fetchSources 查询指定列  未指定则使用默认defaultFetchSources
	 * @return
	 *//*

	public List<PassBean> queryPassDataScroll(QueryBuilder query,String[] fetchSources) throws Exception {

		List<PassBean> list = new ArrayList<PassBean>();
		//Long starttime = System.currentTimeMillis();
		SearchResponse scrollResp = client.prepareSearch(DataOperateClient.metaDataIndexName)
										    .setSearchType(SearchType.SCAN)
										    .setScroll(new TimeValue(60000))
										    .setQuery(query)
										    .setFetchSource(CommonUtil.isEmpty(fetchSources)?defaultFetchSources:fetchSources, null)
										    .setSize(500)
										    .execute()
										    .actionGet(); 
		//Es查询跟踪，定位查询数据总数偶有不准的问题
		StringBuffer sb0 = new StringBuffer("");
		ShardSearchFailure[] failures0 = scrollResp.getShardFailures();
		for(ShardSearchFailure f:failures0){
			sb0.append("ESscroll查询异常:");
			sb0.append(f.reason());
			sb0.append(f.failure());
		}
		if(!"".equals(sb0.toString())){
			logger.error(sb0.toString());				
		}
		//Long querytime = System.currentTimeMillis();
		while (true) {
			//循环提取
			for (SearchHit hit : scrollResp.getHits().getHits()) {
				PassBean bean = new PassBean();			
				String str = hit.getSourceAsString();		
				bean = JsonUtil.readValue(str,PassBean.class);
				list.add(bean);
			}			
			//再次获取数据
			scrollResp = client.prepareSearchScroll(scrollResp.getScrollId())
										.setScroll(new TimeValue(600000))
										.execute()
										.actionGet();
			//Es查询跟踪，定位查询数据总数偶有不准的问题
			StringBuffer sb = new StringBuffer("");
			ShardSearchFailure[] failures = scrollResp.getShardFailures();
			for(ShardSearchFailure f:failures){
				sb.append("ESscroll查询异常:");
				sb.append(f.reason());
				sb.append(f.failure());
			}
			if(!"".equals(sb.toString())){
				logger.error(sb.toString());				
			}
			// Break condition: No hits are returned
			if (scrollResp.getHits().getHits().length == 0) {
				break;
			}
		}
		return list ;
	}
	*/
/**
	 * 查询过车数据 滚动方式获取全部数据，****支持多组索引和多组类型查询****
	 * @param query QueryBuilder
	 * @param fetchSources 查询指定列  未指定则使用默认defaultFetchSources
	 * @return
	 *//*

	public List<PassBean> queryPassDataScroll(String[] indexs,String[] types,QueryBuilder query,String[] fetchSources) throws Exception {
		if(indexs==null || indexs.length<1){
			return new ArrayList<PassBean>();
		}
		List<PassBean> list = new ArrayList<PassBean>();
		//Long starttime = System.currentTimeMillis();
		SearchResponse scrollResp = client.prepareSearch(indexs)
									    .setTypes(types)
										.setSearchType(SearchType.SCAN)
									    .setScroll(new TimeValue(60000))
									    .setQuery(query)
									    .setFetchSource(CommonUtil.isEmpty(fetchSources)?defaultFetchSources:fetchSources, null)
									    .setSize(500)
									    .execute()
									    .actionGet(); 
		//Es查询跟踪，定位查询数据总数偶有不准的问题
		StringBuffer sb0 = new StringBuffer("");
		ShardSearchFailure[] failures0 = scrollResp.getShardFailures();
		for(ShardSearchFailure f:failures0){
			sb0.append("ESscroll查询异常:");
			sb0.append(f.reason());
			sb0.append(f.failure());
		}
		if(!"".equals(sb0.toString())){
			logger.error(sb0.toString());				
		}
		//Long querytime = System.currentTimeMillis();
		while (true) {
			//循环提取
			for (SearchHit hit : scrollResp.getHits().getHits()) {
				PassBean bean = new PassBean();			
				String str = hit.getSourceAsString();		
				bean = JsonUtil.readValue(str,PassBean.class);
				list.add(bean);
			}			
			//再次获取数据
			scrollResp = client.prepareSearchScroll(scrollResp.getScrollId())
										.setScroll(new TimeValue(600000))
										.execute()
										.actionGet();
			//Es查询跟踪，定位查询数据总数偶有不准的问题
			StringBuffer sb = new StringBuffer("");
			ShardSearchFailure[] failures = scrollResp.getShardFailures();
			for(ShardSearchFailure f:failures){
				sb.append("ESscroll查询异常:");
				sb.append(f.reason());
				sb.append(f.failure());
			}
			if(!"".equals(sb.toString())){
				logger.error(sb.toString());				
			}
			// Break condition: No hits are returned
			if (scrollResp.getHits().getHits().length == 0) {
				break;
			}
		}
		return list ;
	}
	*/
/**
	 * 分页查询（不分词），支持顺序配置多个排序
	 * @param indexName 索引名称
	 * @param indexType  索引类型
	 * @param qb    查询语句QueryBuilder 
	 * @param sortField   排序字段
	 * @param orders 排序字段 [username-asc, age-desc] 使用"-"隔开
	 * @param pageNum
	 * @param pageSize
	 * @param fetchSources 指定查询列 ：string数组
	 * @return  SearchResponse 查询结果
	 *//*

	public SearchResponse queryESPageSort (String indexName,String indexType,QueryBuilder queryBuilder,List<String> orders,int from,int pageSize,String[] fetchSources) throws Exception{
	
		//执行ES查询，返回结果Json
		SearchResponse response=null;
		SearchRequestBuilder tmp = null;		
			tmp =  client.prepareSearch(indexName)
			.setTypes(indexType)
			.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
			.setQuery(queryBuilder)
			.setFetchSource(CommonUtil.isEmpty(fetchSources)?defaultFetchSources:fetchSources, null)
			*/
/*.addSort(SortBuilders.scoreSort().order(SortOrder.DESC))*//*
;//必须添加默认排序 否则可能结果不全
			if(orders!= null &&  orders.size() > 0){
				for(String order : orders){
					String key = order.split("-")[0];
					String val = order.split("-")[1];
					if(ORDER_ASC.equals(val.toUpperCase())){
						tmp.addSort(key, SortOrder.ASC);	
					}else{
						tmp.addSort(key, SortOrder.DESC);
					}
				}
			}					
			response =tmp.setFrom(from)
					   .setSize(pageSize)
					   .execute()
					   .actionGet();
			//Es查询跟踪，定位查询数据总数偶有不准的问题
			StringBuilder sb = new StringBuilder("");
			ShardSearchFailure[] failures = response.getShardFailures();
			for(ShardSearchFailure f:failures){
				sb.append("ESpage查询异常:");
				sb.append(f.reason());
				sb.append(f.failure());
			}		
			if(!"".equals(sb.toString())){
				logger.error(sb.toString());				
			}
		return response;
	}
	*/
/**
	 * 分页查询（不分词），支持顺序配置多个排序
	 * @param indexs 索引名称(支持多个)
	 * @param types  索引类型（支持多个）
	 * @param qb    查询语句QueryBuilder 
	 * @param sortField   排序字段
	 * @param orders 排序字段 [username-asc, age-desc] 使用"-"隔开
	 * @param pageNum
	 * @param pageSize
	 * @param fetchSources 指定查询列 ：string数组
	 * @return  SearchResponse 查询结果
	 *//*

	public SearchResponse queryESPageSort (String[] indexs,String[] types,QueryBuilder queryBuilder,List<String> orders,int from,int pageSize,String[] fetchSources) throws Exception{
		//执行ES查询，返回结果Json
		SearchResponse response=null;
		if(indexs==null || indexs.length<1){
			return response;
		}
		SearchRequestBuilder tmp = null;		
			tmp = client.prepareSearch(indexs)
			.setTypes(types)
			.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
			.setQuery(queryBuilder)
			.setFetchSource(CommonUtil.isEmpty(fetchSources)?defaultFetchSources:fetchSources, null)
			*/
/*.addSort(SortBuilders.scoreSort().order(SortOrder.DESC))*//*
;//必须添加默认排序 否则可能结果不全
			if(orders!= null &&  orders.size() > 0){
				for(String order : orders){
					String key = order.split("-")[0];
					String val = order.split("-")[1];
					if(ORDER_ASC.equals(val)){
						tmp.addSort(key, SortOrder.ASC);	
					}else{
						tmp.addSort(key, SortOrder.DESC);
					}
				}
			}					
			response =tmp.setFrom(from)
					   .setSize(pageSize)
					   .execute()
					   .actionGet();
			//Es查询跟踪，定位查询数据总数偶有不准的问题
			StringBuilder sb = new StringBuilder("");
			ShardSearchFailure[] failures = response.getShardFailures();
			for(ShardSearchFailure f:failures){
				sb.append("ESpage查询异常:");
				sb.append(f.reason());
				sb.append(f.failure());
			}		
			if(!"".equals(sb.toString())){
				logger.error(sb.toString());				
			}
		return response;
	}
	*/
/**
	 * 执行ES简单的查询QueryBuilder
	 * @param index 索引
	 * @param type  类型
	 * @param qb    查询语句QueryBuilder
	 * @param fetchSources 指定查询列 ：string数组
	 * @return  SearchResponse 查询结果
	 *//*

	public SearchResponse queryESsimple (String index,String type,QueryBuilder queryBuilder,int size,String[] fetchSources){
		//执行ES查询，返回结果Json
		SearchResponse response=null;
		try {
			response = client.prepareSearch(index)
			.setTypes(type)
			.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
			.setQuery(queryBuilder)
			.setFetchSource(CommonUtil.isEmpty(fetchSources)?defaultFetchSources:fetchSources, null)
			.setFrom(0).setSize(size)
			.execute()
			.actionGet();
			//Es查询跟踪，定位查询数据总数偶有不准的问题
			StringBuilder sb = new StringBuilder("");
			ShardSearchFailure[] failures = response.getShardFailures();
			for(ShardSearchFailure f:failures){
				sb.append("ESpage查询异常:");
				sb.append(f.reason());
				sb.append(f.failure());
			}		
			if(!"".equals(sb.toString())){
				logger.error(sb.toString());				
			}
		} catch (ElasticsearchException e) {
			e.printStackTrace();
		}
		
		return response;
	}
	*/
/**
	 * 执行ES简单的查询QueryBuilder
	 * @param indexs 索引(支持多个)
	 * @param types  类型（支持多个）
	 * @param qb    查询语句QueryBuilder
	 * @param fetchSources 指定查询列 ：string数组
	 * @return  SearchResponse 查询结果
	 *//*

	public SearchResponse queryESsimple (String[] indexs,String[] types,QueryBuilder queryBuilder,int size,String[] fetchSources){
		//执行ES查询，返回结果Json
		SearchResponse response=null;
		if(indexs==null || indexs.length<1){
			return response;
		}
		try {
			response = client.prepareSearch(indexs)
			.setTypes(types)
			.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
			.setQuery(queryBuilder)
			.setFetchSource(CommonUtil.isEmpty(fetchSources)?defaultFetchSources:fetchSources, null)
			.setFrom(0).setSize(size)
			.execute()
			.actionGet();
			//Es查询跟踪，定位查询数据总数偶有不准的问题
			StringBuilder sb = new StringBuilder("");
			ShardSearchFailure[] failures = response.getShardFailures();
			for(ShardSearchFailure f:failures){
				sb.append("ESpage查询异常:");
				sb.append(f.reason());
				sb.append(f.failure());
			}		
			if(!"".equals(sb.toString())){
				logger.error(sb.toString());				
			}
		} catch (ElasticsearchException e) {
			e.printStackTrace();
		}
		
		return response;
	}
	*/
/**
	 * 查询总数count
	 * 
	 * @param index
	 * @param type
	 * @param queryBuilder
	 * @return
	 *//*

	public Long queryEsCount(String indexNameCons,String typeNameCons,QueryBuilder queryBuilder){
		//执行ES查询
		CountResponse resCount = null;
		try{
			resCount = client.prepareCount(indexNameCons)
					.setTypes(typeNameCons)
					.setQuery(queryBuilder)
					.execute()
					.actionGet();
			*/
/*
				ShardSearchFailure[] failures = resCount.getShardFailures();
				for(ShardSearchFailure f:failures){
					System.out.println(f.reason());
					System.out.println(f.failure());
				}
			*//*

			StringBuilder sb = new StringBuilder("");
			ShardOperationFailedException []  failures = resCount.getShardFailures();
			for(ShardOperationFailedException f:failures){
				sb.append("EScount查询异常:\n"+f.reason());				
			}
			if(!"".equals(sb.toString())){
				logger.error(sb.toString());				
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return resCount.getCount();
	}
	*/
/**
	 * 查询总数count
	 * 
	 * @param indexs Es索引，支持多个
	 * @param types Es类型，支持多个
	 * @param queryBuilder
	 * @return
	 *//*

	public Long queryEsCount(String[] indexs,String[] types,QueryBuilder queryBuilder){
		if(indexs==null || indexs.length<1){
			return 0L;
		}
		//执行ES查询
		CountResponse resCount = null;
		try{
			resCount = client.prepareCount(indexs)
					.setTypes(types)
					.setQuery(queryBuilder)
					.execute()
					.actionGet();
			*/
/*
				ShardSearchFailure[] failures = resCount.getShardFailures();
				for(ShardSearchFailure f:failures){
					System.out.println(f.reason());
					System.out.println(f.failure());
				}
			*//*

			StringBuilder sb = new StringBuilder("");
			ShardOperationFailedException []  failures = resCount.getShardFailures();
			for(ShardOperationFailedException f:failures){
				sb.append("EScount查询异常:\n"+f.reason());				
			}
			if(!"".equals(sb.toString())){
				logger.error(sb.toString());				
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return resCount.getCount();
	}
	*/
/**
	 * 过车数据：将返回的Response转换为List	
	 *//*

	public  static void  convertPassResponse2List(List<PassBean> list ,SearchResponse searchResponse) throws Exception{
	
		for(SearchHit  searchHit: searchResponse.getHits().getHits()){
		
			PassBean bean = new PassBean();			
			String str = searchHit.getSourceAsString();					
			bean =  JsonUtil.readValue(str,PassBean.class);			
			*/
/**
			 * 将非正常车牌统一设置  
			 * null,"0","无牌车","未识别","-"
			 		
			setIllegalPlageNumber(bean);
			*//*

			list.add(bean);
		}
	}
	*/
/**
	 * 过车数据：将返回的Response转换为Map :｛count:总数，time:耗时，list:数据集合｝	
	 * 
	 *//*

	public static  void convertPassResponse2Map(Map<String, Object> map, SearchResponse searchResponse) throws Exception{
		List<PassBean> list = new ArrayList<PassBean>();
		if(searchResponse==null || searchResponse.getHits()==null){
			map.put("count",0);
			map.put("time", 0.0141);
			map.put("list",list);
			return ;
		}
		long count = searchResponse.getHits().getTotalHits();
		Long time = searchResponse.getTookInMillis();
		
		map.put("count",count);	
		map.put("time", (double)time/1000);
	   
		for(SearchHit  searchHit: searchResponse.getHits().getHits()){
			PassBean bean = new PassBean();			
			String str = searchHit.getSourceAsString();
						
			bean =  JsonUtil.readValue(str,PassBean.class);
			
			*/
/**
			 * 将非正常车牌统一设置  
			 * null,"0","无牌车","未识别","-"
			 		
			setIllegalPlageNumber(bean);*//*


			list.add(bean);
		}
		
		map.put("list",list);		
	}
	*/
/**
	 * 分析结果：将返回的Response转换为List
	 *//*

	public static  void convertResultResponse2List(List<ResultBean> list, SearchResponse searchResponse) throws Exception{
		for(SearchHit  searchHit: searchResponse.getHits().getHits()){
			ResultBean bean = new ResultBean();			
			String str = searchHit.getSourceAsString();						
			bean =  JsonUtil.readValue(str,ResultBean.class);					
			list.add(bean);
		}			
	}
	*/
/**
	 * 分析结果：将返回的Response转换为Map :｛count:总数，time:耗时，list:数据集合}
	 *//*

	public static  void convertResultResponse2Map(Map<String, Object> map, SearchResponse searchResponse) throws Exception{
		List<ResultBean> list = new ArrayList<ResultBean>();
		if(searchResponse==null || searchResponse.getHits()==null){
			map.put("count",0);
			map.put("time", 0.0141);
			map.put("list",list);
			return ;
		}
		long count = searchResponse.getHits().getTotalHits();
		Long time = searchResponse.getTookInMillis();
		
		map.put("count",count);	
		map.put("time", (double)time/1000);
	   
		for(SearchHit  searchHit: searchResponse.getHits().getHits()){
			ResultBean bean = new ResultBean();			
			String str = searchHit.getSourceAsString();						
			bean =  JsonUtil.readValue(str,ResultBean.class);			
			list.add(bean);
		}		
		map.put("list",list);		
	}
	*/
/**
	 * 获取32位UUID，不含"-"
	 * @return
	 *//*

	public static String getUUID(){
		    return  UUID.randomUUID().toString().replace("-", "");	        
	}
	*/
/**
	 * 构造时间对象:yyyy-MM-dd HH:mm:ss
	 * @param dateString
	 * @return
	 * @throws Exception
	 *//*

	public static Date parseDate(String dateString)  throws Exception {  
	        if ((dateString == null) || (dateString.trim().equals("")))  
	            return null;  
	        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  	        
	        try {  
	            return sdf.parse(dateString);  
	        } catch (ParseException localParseException) {  
	            throw new Exception("日期解析出错！", localParseException);  
	        }  
	}  
	public static String getDateStr(Date date ,String format){
		if(format == null ){
			format  = "yyyy-MM-dd HH:mm:ss" ;
		}
		return new SimpleDateFormat(format).format(date);
	}
	
    */
/**
     * 将无牌车的车牌号统一设置为"0",其他字段设为 "-"
     * TaskID taskName为空 
     * @param passBean
     *//*

    public static void  setIllegalResultBean(ResultBean bean){ 	
	   		 bean.setBodyColor(ILLEGAL_PLATE_FIELD_CODE); 
	   		 bean.setBodyColorName(ILLEGAL_PLATE_FIELD_CODE);
	   		 bean.setLogoInfo(ILLEGAL_PLATE_FIELD_CODE);
	   		 bean.setPlateNum(ILLEGAL_PLATE_NUMBER_NAME);
	   		 bean.setPlateType(ILLEGAL_PLATE_FIELD_CODE);
	   		 bean.setPlateTypeName(ILLEGAL_PLATE_FIELD_CODE);
	   		 bean.setSumcount(0l);
	   		 bean.setGroupNum(0l);
	   		 bean.setKakoNum(0l);
	   		 bean.setUuid(getUUID());	   		 
    }
    */
/**
     * 判断是否为未识别车辆
     * @param PassBean
     * @return  boolean 未识别：true 已识别：false
     * *//*

    public static boolean hasNoRecognized(PassBean pb){
    	if(pb!=null&&StringUtils.isBlank(pb.getPlateType())||pb.getPlateType().equals("41")||StringUtils.isBlank(pb.getPlateNumNond())
				||pb.getPlateNumNond().length()<7){		 
    		return true;
		}
    	return false;
    }
    */
/**
     * 通过plateType判断是否为未识别车辆
     * @param PassBean
     * @return  boolean 未识别：true 已识别：false
     * *//*

    public static boolean hasNoRecognizedByP(PassBean pb){
    	if(pb.getPlateType().equals("41")){		 
    		return true;
		}
    	return false;
    }
    */
/**
     * 判断是否为未识别车辆 -- 通过车辆分析算法专用
     * @param PassBean
     * @return  boolean
     * *//*

    public static boolean hasRecognized4Through(PassBean pb){
    	if(pb == null || StringUtils.isBlank(pb.getPlateNumNond()) || pb.getPlateNumNond().length()<7){ 
    		return true;
		}
    	return false;
    }
    */
/**
	 * 刷新内存中存储的索引列表
	 *//*

	public void refreshIndex(){
		try {
			ClusterState cs = client.admin()
					.cluster().prepareState()
					.execute().actionGet().getState();

			String[] allIndex = cs.getMetaData().concreteAllOpenIndices();
			Set<String> inteIndex = this.indexSet;
			for(String index:allIndex) {
				if(index.indexOf(GlobalConfig.getConfig("metaDataIndexName"))>-1){
					inteIndex.add(index);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
//			conESUtil.freeClient(client);
		}
	}
}*/
